<?php
	/*define( "DATABASE_SERVER", "localhost" );
	define( "DATABASE_USERNAME", "autogator" );
	define( "DATABASE_PASSWORD", "123456" );
	define( "DATABASE_NAME", "autogator-live" );*/
//createThings(0,20,NULL);
$_REQUEST['key'] = '';
$_REQUEST['field'] = '';
$_REQUEST['sort'] = '';
function createThings($startpoint,$perpage,$currentkey)
{
		

	//connect to the database
	/*$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD) or die(mysql_error());
	//select the database
	mysql_select_db( DATABASE_NAME );*/
	
	if($currentkey)
	{
		$key = $currentkey;
	}
	else
	{
		$key = $_REQUEST['key'];/**/
	}
	
	/**/if($_REQUEST['field']){
		$order_string = " ORDER BY ".$_REQUEST['field']." ".$_REQUEST['sort'];
	}else{
		$order_string = " ORDER BY vehicle_id ASC";
	}
	
	if($key)
	{
		
		$queryString = "select vehicle_id, year, make, model, first_name, v_city, v_state, update_date FROM `vehicle_backup` WHERE (vehicle_id LIKE '%".$key."%' OR year LIKE '%".$key."%' OR make LIKE '%".$key."%' OR model LIKE '%".$key."%' OR bid_price LIKE '%".$key."%' OR asking_price LIKE '%".$key."%' OR first_name LIKE '%".$key."%' OR phone LIKE '%".$key."%' OR city LIKE '%".$key."%' OR state LIKE '%".$key."%')".$order_string." LIMIT $startpoint, $perpage";	
		}
		
	else
	{
		$queryString = "select vehicle_id, year, make, model, first_name, v_city, v_state, update_date FROM `vehicle_backup` ".$order_string." LIMIT $startpoint,$perpage";
	}
	$result = '';
	$vh_del_q = mysql_query($queryString) or die("Query ERROR1".$queryString);
	$result.= "<table cellpadding='2'>";
	$i = 0;
	/*<tr>
	<td></td>
	<td><b>&nbsp;Bid #&nbsp;</b></td>
	<td><b>&nbsp;Year&nbsp;</b></td>
	<td><b>&nbsp;Make&nbsp;</b></td>
	<td><b>&nbsp;Model&nbsp;</b></td>
	<td><b>&nbsp;Seller&nbsp;</b></td>
	<td><b>&nbsp;City / State&nbsp;</b></td>
	<td><b>&nbsp;Last Update&nbsp;</b></td>
	</tr>*/
	while ($row_1 =  mysql_fetch_object($vh_del_q)) 
		{
			 $i++;
			 $result.= "<tr><td width='30'><input type='checkbox' value='".$row_1->vehicle_id."' name='check[]'/></td><td width='60'>&nbsp;".$row_1->vehicle_id."&nbsp;</td><td width='60'>&nbsp;".$row_1->year."&nbsp;</td><td width='150'>&nbsp;".$row_1->make."&nbsp;</td><td width='150'>&nbsp;".$row_1->model."&nbsp;</td><td width='150'>&nbsp;".$row_1->first_name."&nbsp;</td><td width='150'>&nbsp;".$row_1->v_city."/".$row_1->v_state."&nbsp;</td><td width='150'>&nbsp;".$row_1->update_date."&nbsp;</td></tr>";
        }
	$result.= "</tr></table>";

	return $result;
}
?>